import App from './App.vue'
import { createSSRApp } from 'vue'
import { createPinia } from 'pinia'

// 按需引入uview-plus组件和工具
import { setConfig, mount$u } from './uni_modules/uview-plus/index.js'
import { mixin } from './uni_modules/uview-plus/libs/mixin/mixin.js'
import { mpMixin } from './uni_modules/uview-plus/libs/mixin/mpMixin.js'

// 按需引入组件
import uIcon from './uni_modules/uview-plus/components/u-icon/u-icon.vue'
import uImage from './uni_modules/uview-plus/components/u-image/u-image.vue'
import uPopup from './uni_modules/uview-plus/components/u-popup/u-popup.vue'
import uInput from './uni_modules/uview-plus/components/u-input/u-input.vue'

export function createApp() {
  const app = createSSRApp(App)
	const pinia = createPinia()

  // 按需注册组件
  app.component('u-icon', uIcon)
  app.component('u-image', uImage)
  app.component('u-popup', uPopup)
  app.component('u-input', uInput)

  // 挂载uview-plus工具函数和mixin
  mount$u()
  app.mixin(mixin)

  app.use(pinia)
  return {
    app
  }
}
